;---------------------------------------------------------------------
;
; File: example_d.sexp
; Examples that demonstrate the main features of SIF03.
;
; Copyright (C) 2006-2008 by Ariel Ortiz <ariel.ortiz@itesm.mx>
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation, either version 3 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program.  If not, see <http://www.gnu.org/licenses/>.
;
;---------------------------------------------------------------------

(define y 10)
(define z 100)
(define baz (fn (x) (begin (define z 0)
                           (set! x (+ x y))
                           (set! y (- y 1))
                           (set! z (+ z 1))
                           (+ x y z))))

(define i 1)
(define r 1)
(while (< i 11) (begin (set! r (* r i))
                       (if (= i 5) (break) ())
                       (set! i (+ i 1))))

                   ; Displayed results:
                   ;
(print 12 3 456)   ;         123456
(baz 20)           ;         40
y                  ;         9
z                  ;         100
r                  ;         120
i                  ;         5
